﻿package imvu.rbox.struct
{
	import anshe.struct.ExUserNames;
	import anshe.struct.game.GRoomInfo;
	
	import imvu.rbox.event.BoxEvent;
	
	public class CGameRoomInfo extends GRoomInfo
	{
		public var gameModel:Number;		//	游戏模式（取值为游戏模式中相关值）
		public var gameSpeed:Number;		//	游戏起始速度
		public var boxNumber:Number;		//	方块数（游戏难度）
		public var maxTime:Number;			//	最长的游戏时间（分钟为单位）
		public var seatArray:Array;			//	各坐位状态
		public var gameData:Array;			//	游戏中方块出现的顺序
		
		private var roomMaster:ExUserNames;	//	房主昵称对象		
		
		public function CGameRoomInfo()
		{
			this.roomID = 1;
			this.soName = "";
			this.master = "";
			this.nowPlayer = 0;
			this.maxPlayer = 6;
			this.isPlaying = false;
			this.gameData = new Array();
			
			this.gameSpeed = BoxEvent.MIN_SPEED;
			this.gameModel = BoxEvent.GAME_MODEL;
			this.boxNumber = BoxEvent.NORMAL_GAME;
			this.maxTime = 0;
			this.seatArray = new Array(1,1,1,1,1,1);			
		}		
		
		public function get masterName():String
		{
			return this.master
		}
		
		public function AddGameData(array:Array):void
		{
			this.gameData = this.gameData.concat(array);
		}	
		
		public function get nowBox():Number
		{
			// trace("当前数据数组：" + this.gameData);
			
			if(this.gameData.length > 0)
			{
				return this.gameData.shift();
			}
			return 0;
		}
		
		public override function toString():String
		{
			var str:String = super.toString();
			
			return 	str + 
					" master: " + this.masterName +
					" speed: " + this.gameSpeed +
					" model: " + this.gameModel +
					" maxtime: " + this.maxTime +
					" boxes: " + this.boxNumber;
		}
		
		//---------------------------------------------------------
		
		protected override function UpdataFromObject(obj:Object):void
		{
			// trace("getData::!!");
			// for(var i:* in obj)	trace("---> " + i + " : " + obj[i]);
			super.UpdataFromObject(obj);		
			
			this.boxNumber = Boolean(Number(obj.boxNumber)) ? BoxEvent.HARD_GAME : BoxEvent.NORMAL_GAME;
			this.gameModel = Boolean(Number(obj.gameModel)) ? BoxEvent.GAME_MODEL : BoxEvent.TIME_MODEL;
			this.gameSpeed = Number(obj.gameSpeed);
			this.seatArray = obj.seatArr;
			
		}		
	}
}